﻿using Sl.Upload.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Sl.Upload.Models;

namespace Sl.Upload.Tool
{
    public class Thumbnail : IThumbnail
    {
        public List<CutInfo> GetThumbnail(string type, List<CutRule> cutList, string savePath, IThumbanailRule thumbanailRule)
        {
            List<SectionSize> li = thumbanailRule.GetSectionSize(type);
            List<CutInfo> cutInfoList = new List<CutInfo>();
            for (int i = 0; i < li.Count; i++)
            {
                CutInfo cutInfo = new CutInfo();
                cutInfo.Mode = cutList == null || cutList.Count == 0 ? true : false;
                cutInfo.Width = li[i].Width;
                cutInfo.Height = li[i].Height;
                if (cutList != null && cutList.Count > 0)
                {
                    cutInfo.RatioHeight = cutList[i].RatioHeight;
                    cutInfo.RatioWidth = cutList[i].RatioWidth;
                    cutInfo.X = cutList[i].X;
                    cutInfo.Y = cutList[i].Y;
                }
                cutInfo.GeneratePath = savePath.Replace("Org", li[i].Name);
                cutInfoList.Add(cutInfo);
            }
            return cutInfoList;
        }
    }
}
